package com.bobi.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bobi.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.Date;

/**
 * 职工(BobiStaff)实体类
 *
 * @author makejava
 * @since 2023-07-02 16:30:09
 */
@Data
@TableName("bobi_staff")
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Staff extends BaseEntity {
    private static final long serialVersionUID = -68817987277822632L;

    /**
     * 职工姓名
     */
    private String name;
    /**
     * 既是手机号又是账号
     */
    private String telephone;
    /**
     * 账号密码
     */
    private String password;
    /**
     * 员工住址
     */
    private String address;
    /**
     * 入职时间
     */
    private Date entryTime;
    /**
     * 离职时间
     */
    private Date leaveTime;
    /**
     * 是否是超级管理员true/false，超级管理员可以有多个
     */
    private Integer supperAdmin;


    public QueryWrapper<Staff> initWrapper(Staff staff) {
        if(staff.getId() != null || staff.getName() != null) {
            QueryWrapper<Staff> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq(StringUtils.isNotBlank(staff.getId()), "id", staff.getId());
            queryWrapper.eq(StringUtils.isNotBlank(staff.getName()), "name" ,staff.getName());
            return queryWrapper;
        }
        return null;
    }
}

